class MilePostModel {
  int? errcode;
  String? errmsg;
  List<Data>? data;
  String? message;

  MilePostModel({this.errcode, this.errmsg, this.data, this.message});

  MilePostModel.fromJson(Map<String, dynamic> json) {
    errcode = json['errcode'];
    errmsg = json['errmsg'];
    if (json['data'] != null) {
      data = <Data>[];
      json['data'].forEach((v) {
        data!.add(new Data.fromJson(v));
      });
    }
    message = json['message'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['errcode'] = this.errcode;
    data['errmsg'] = this.errmsg;
    if (this.data != null) {
      data['data'] = this.data!.map((v) => v.toJson()).toList();
    }
    data['message'] = this.message;
    return data;
  }
}

class Data {
  int? id;
  String? name;
  String? deadline;
  String? reachedDate;
  bool? isReached;
  int? progress;
  List<Tasks>? tasks;

  Data(
      {this.id,
        this.name,
        this.deadline,
        this.reachedDate,
        this.isReached,
        this.progress,
        this.tasks});

  Data.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    deadline = json['deadline'];
    reachedDate = json['reached_date'];
    isReached = json['is_reached'];
    progress = json['progress'];
    if (json['tasks'] != null) {
      tasks = <Tasks>[];
      json['tasks'].forEach((v) {
        tasks!.add(new Tasks.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    data['deadline'] = this.deadline;
    data['reached_date'] = this.reachedDate;
    data['is_reached'] = this.isReached;
    data['progress'] = this.progress;
    if (this.tasks != null) {
      data['tasks'] = this.tasks!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Tasks {
  int? id;
  String? name;
  String? description;
  List<UserName>? userName;
  List? tagName;
  String? planDateBegin;
  String? planDateEnd;
  String? state;
  int? progress;
  bool? isFocus;

  Tasks(
      {this.id,
        this.name,
        this.description,
        this.userName,
        this.tagName,
        this.planDateBegin,
        this.planDateEnd,
        this.state,
        this.progress,
        this.isFocus});

  Tasks.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    description = json['description'];
    if (json['user_name'] != null) {
      userName = <UserName>[];
      json['user_name'].forEach((v) {
        userName!.add(new UserName.fromJson(v));
      });
    }
    if (json['tag_name'] != null) {
      tagName = [];
      json['tag_name'].forEach((v) {
        // tagName!.add(new TagName.fromJson(v));
      });
    }
    planDateBegin = json['plan_date_begin'];
    planDateEnd = json['plan_date_end'];
    state = json['state'];
    progress = json['progress'];
    isFocus = json['is_focus'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    data['description'] = this.description;
    if (this.userName != null) {
      data['user_name'] = this.userName!.map((v) => v.toJson()).toList();
    }
    if (this.tagName != null) {
      data['tag_name'] = this.tagName!.map((v) => v.toJson()).toList();
    }
    data['plan_date_begin'] = this.planDateBegin;
    data['plan_date_end'] = this.planDateEnd;
    data['state'] = this.state;
    data['progress'] = this.progress;
    data['is_focus'] = this.isFocus;
    return data;
  }
}

class UserName {
  int? id;
  String? name;

  UserName({this.id, this.name});

  UserName.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    return data;
  }
}
